package cn.itcast.cd.action;

import java.util.List;

import cn.itcast.cd.domain.Permission;
import cn.itcast.cd.domain.Product;
import cn.itcast.cd.service.IProductService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ProductAction extends ActionSupport {

	
	private IProductService productService;
	
	private Permission permission = new Permission();
	public Permission getPermission() {
		return permission;
	}

	private Product Product = new Product();
	
	
	public Product getProduct() {
		return Product;
	}

	public void setproductService(IProductService productService) {
		this.productService = productService;
	}

	public String save(){
		
		return SUCCESS;
	}
	
	public String delete(){
		productService.delete(Product.getId());
		return SUCCESS;
	}
	
	public String list(){
		String conditions = "FROM Product";
		List<Product> products = productService.queryEntity(conditions, null);
		ActionContext.getContext().put("products", products);
		return "list";
	}
	
}
